﻿using MediatR;
using SheepStorage.API.Application.Command.SheepMomPergnantCommand;
using SheepStorage.API.Application.Command.YourTableNameCommand;
using SheepStorage.API.Baseclass;
using SheepStorage.Domain.Entity;
using SheepStorage.Service.Interface;

namespace SheepStorage.API.Application.CommandHandlers.SheepMomPergnantHandler
{
    public class SheepMomPergnantUpdateCommandHandler : IRequestHandler<SheepMomPergnantUpdateCommand, Results<int>>
    {
        private readonly ISheepMomPergnantService _sheepMomPergnantService;
        public SheepMomPergnantUpdateCommandHandler(ISheepMomPergnantService sheepMomPergnantService)
        {
            _sheepMomPergnantService = sheepMomPergnantService;
        }
        public async Task<Results<int>> Handle(SheepMomPergnantUpdateCommand request, CancellationToken cancellationToken)
        {
            var Pergnan = new SheepMomPergnant()
            {
                 MomPergnantId=request.MomPergnantId,
                BuildingManagementId = request.BuildingManagementId,

                MomPergnantCount = request.MomPergnantCount,
                MomPergnantDate = request.MomPergnantDate,

                MomPergnantGestation = request.MomPergnantGestation,
                ElEarTag = request.ElEarTag,
                MomPergnantPrincipal = request.MomPergnantPrincipal,
                MomPergnantResult = request.MomPergnantResult,
                MomPergnantType = request.MomPergnantType,
                OverBit = request.OverBit,
                SheepFieldId = request.SheepFieldId,

                MomPergnantBuilding = request.MomPergnantBuilding,
                MomPergnantField = request.MomPergnantField,
            };

            var result = await _sheepMomPergnantService.UpdateSheepMomPergnant(Pergnan);
            return Results<int>.DataResult(result);
        }
    }
}
